package cn.iocoder.mall.admin.mq;

import cn.iocoder.common.framework.constant.CommonConstant;
import cn.iocoder.common.utils.common.api.vo.AppMessageTOMQDTO;
import cn.iocoder.mall.admin.client.SmsClient;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/***
 *@author yinxucun
 *@date 2019-12-04 16:56 
 */
@Service
@Slf4j
@RocketMQMessageListener(topic = CommonConstant.SMS_ROCKET_APPMESSAGE, consumerGroup = "mall_sms_message_consumer")
public class AppMessageConsumer implements RocketMQListener<AppMessageTOMQDTO> {

    @Resource(name = "smsAliYunClient")
    SmsClient client;

    @Override
    public void onMessage(AppMessageTOMQDTO message) {
        log.info(message.toString());
        client.singleSend(message.getMobile(),"",message.getTemplateCode(),"",message.getParams());

    }
}
